package zhouzhouyongche.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import zhouzhouyongche.client_util.Json;
import zhouzhouyongche.service.SiteService;

@Controller
@Action(value = "site")
public class SiteAction extends BaseAction {

	@Autowired
	private SiteService siteService;
	
	private int cityId;
	private String siteName;
	
	public void getSite() {
		List list = siteService.getSites(cityId);
		writeJson(list);
	}
	
	public void addSite() {
		Json json = new Json();
		try {
			siteService.addSite(cityId, siteName);
			json.setSuccess(true);
			json.setMsg("添加站点成功");
		} catch (Exception e) {
			e.printStackTrace();
			json.setSuccess(false);
			json.setMsg("添加站点失败");
		}
		writeJson(json);
	}

	public int getCityId() {
		return cityId;
	}

	public void setCityId(int cityId) {
		this.cityId = cityId;
	}

	public String getSiteName() {
		return siteName;
	}

	public void setSiteName(String siteName) {
		this.siteName = siteName;
	}
	
}
